<template>
	<div style="width: 100%;height: 100%;">
       <myMessage :myData="data"></myMessage>
	</div>

</template>

<script>
import myMessage from "../../real-components/myMessage";
import {mapGetters,mapActions,mapMutations} from "vuex";
import { Toast } from '../../utils/toast.js';
import {getNews} from '../../api/wxh/getData.js';
import axios from 'axios';
import {zxBase,zxSessionId} from '../../api/zxApi.js';
import {reFreshUserInfo} from '../../utils/WXH/login.js';
import {MessageBox} from "../../ui-components"
export default {
  	data () {
    	return {
			page:'myMessage',
			type:{
				myMessage:'myMessage',
			},
			data: null,
			num: null
		}
	},
	async mounted() {

      if(!this.isLogin()) {
        MessageBox.confirm('请先登录！')
          .then(action => {
            this.$router.push({path: 'login',query: {page: 1}});
          })
          .catch(error => {
            console.log(error);
          })
      } else {

        await this.getUserInfo();
        this.initData();
      }

	},
	computed: {
		...mapGetters([

        ]),
    ...mapGetters('wxh', [
			'sessionId',
			'login'
		]),
	},
	created() {

	},
	components: {
        "myMessage": myMessage,
    },
    methods: {
    	...mapActions('wxh', [
		  'getUserInfo'
		])
		,
		...mapMutations('wxh', [
		  'USER_INFO',
		  'LOGO_OUT',
		  'LOGO_IN',
		  'CLEAR_INFO'
		]),
		async initData () {
		   //调用個人中心的方法刷新用户信息 防止vuex用户信息失效
			reFreshUserInfo(this);
			//请求消息列表
			this.getNewsList();
		},
		getNewsList(){
			let params = {
        			isPage:"false",//是否分頁  false不分頁
        			enterpriseCode:window.api.enterpriseCode
        		};

//      		window.api.local_host
//				let url = "http://172.19.5.131:33004/messageVue/findMessageList"
//      		let config = {
//	            	url:window.api.local_host+"/messageVue/findMessageList",
//	            	method: 'Post',
//	            	headers: {'sessionId': this.sessionId},
//	            	data:params
//	           	};
	           	let config = {
	            	url:window.api.customer_host+"/messageVue/findMessageList",
	            	method: 'POST',
	            	headers: {'sessionId': this.sessionId},
	            	data:params
	           	};
	           axios(config).then((res)=>{
	           		console.log(res.data.data[0].results)
		           	if(res.data.returncode == 0) {
						Toast({
						  message: req.errmsg,
						  type: 'fail',
						  duration: 2000
						});
						return
					}
		           	console.log(res.data.data[0].results,'消息')
	           		this.data = res.data.data[0].results;
	           })
		}
		,
		isLogin() {
			return this.login;

		}
    },
	updated() {
		//页面更新完毕

	}
}
</script>

<!-- Add "scoped" attribute to limit CSS to this component only -->
<style scoped>
	.box {
		/* display: flex; */
	}
	.style-components {
		display: flex;
		flex-flow: column nowrap;
	}
	.container {
		width: 800px;
		height: 300px;
		border: 1px solid red;
	}
</style>
